package se.webbzon.boltzmann.game.sequence.condition;

import se.webbzon.boltzmann.game.object.player.AbstractPlayerCharacter;
import se.webbzon.boltzmann.game.sequence.Sequence;
import se.webbzon.oschi01.worldobject.WorldObject;

public class HasGamepad extends ConditionSequenceNode {

	/*============================================================
	Constructors
	============================================================*/

	public HasGamepad(Sequence sequence) {
		super(sequence,null,null);
	}
	
	/*============================================================
	Public Methods
	============================================================*/

	@Override public boolean isTrue() {
		WorldObject instance = getSequence().getBinding(this);
		if (instance == null)
			instance = getSequence().getBinding("player");
		if (instance instanceof AbstractPlayerCharacter) {
			AbstractPlayerCharacter player = (AbstractPlayerCharacter) instance;
			return player.getPlayer().getInput().hasSecondaryAxis();
		} else
			return false;
	}
	
}
